package com.xframe.domain.emnus;

import lombok.Getter;

import java.util.Arrays;
/**
 * 通用字段枚举
 */
@Getter
public enum PublicFieldEnum {

    CREATE_BY("createBy"),
    CREATE_TIME("createTime"),
    UPDATE_BY("updateBy"),
    UPDATE_TIME("updateTime"),
    VERSION("version"),
    DEL_FLAG("delFlag");

    private final String value;


    PublicFieldEnum(String value) {
        this.value = value;
    }

    public static Boolean isPublicField(String fieldName){
        return Arrays.stream(PublicFieldEnum.values()).map(PublicFieldEnum::getValue).anyMatch(e->e.equals(fieldName));
    }

    public static Boolean isPublicFieldNoDelFlag(String fieldName){
        return Arrays.stream(PublicFieldEnum.values()).map(PublicFieldEnum::getValue).anyMatch(e->e.equals(fieldName) && !e.equals("delFlag"));
    }

    public static Boolean isFormField(String fieldName){
        return Arrays.stream(PublicFieldEnum.values()).map(PublicFieldEnum::getValue).anyMatch(e->e.equals(fieldName)
                && !e.equals("delFlag") && !e.equals("version"));
    }

    public static Boolean isNotPublicField(String fieldName){
        return !PublicFieldEnum.isPublicField(fieldName);
    }
}
